package wzc.design_pattern.behaviour.state;

/**
 * @Author 那和不是个啥
 * @Date 2025/7/20
 * @Description
 */

public class SoldState implements VendingMachineState {
    private VendingMachine vendingMachine;

    public SoldState(VendingMachine vendingMachine) {
        this.vendingMachine = vendingMachine;
    }

    @Override
    public void insertCoin() {
        System.out.println("商品正在出货，请稍后再试。");
    }

    @Override
    public void ejectCoin() {
        System.out.println("商品正在出货，不能退币。");
    }

    @Override
    public void pressButton() {
        System.out.println("商品正在出货，不能再次按按钮。");
    }

    @Override
    public void dispense() {
        System.out.println("商品已出货。");
        // 出货后返回没有投币状态
        vendingMachine.setCurrentState(new NoCoinState(vendingMachine));
    }
}
